package GameLogic
{
	import BasicEngine.Dispatcher;
	import DataStore.BmpDataPool;
	import flash.display.Bitmap;
	import flash.display.BitmapData;
	import flash.display.Shape;
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.events.MouseEvent;
	import flash.ui.Mouse;
	import flash.ui.MouseCursor;
	public class Head extends Sprite
	{
		public var Frame:Bitmap;
		private var pics:Vector.<BitmapData>;
		private var index:int = 0;
		private var privateTimer:int = 0;
		private var shape:Shape;
		private var isAnimation:Boolean = false;
		
		public function Head()
		{
			pics = new Vector.<BitmapData>();
			for (var i:int = 1; i < 11; i++)
			{
				pics.push(BmpDataPool.LuaEditorPool[i + 122]);
			}
			for (var j:int = 1; j < 9 ;j++ )
			{
				pics.push(BmpDataPool.LuaEditorPool[122+10-j]);
			}
			Frame = new Bitmap(pics[index]);
			shape = new Shape();
			shape.graphics.beginFill(0xffffff, 1);
			shape.graphics.drawCircle(24, 29, 28);
			addChild(shape);
			addChild(Frame);
			this.addEventListener(Event.ENTER_FRAME, function(e:Event):void
			{
				if (Dispatcher.Clock.SystemTime - privateTimer > 200)
				{
				    if (index > pics.length - 1)
				       index = 0;
				    Frame.bitmapData = pics[index];
					if (isAnimation)
				    {
				       index++;
				    }
					privateTimer = Dispatcher.Clock.SystemTime;
					if (Dispatcher.Clock.SystemTime % 10000 == 0)
					{
						isAnimation = true;
					}
				}
			});
			this.addEventListener(MouseEvent.CLICK, function(e:MouseEvent):void
			{
				trace("ok,头像");
			});
			this.addEventListener(MouseEvent.MOUSE_OVER, function(e:MouseEvent):void
			{
				Mouse.cursor = MouseCursor.BUTTON;
				isAnimation = true;
			});
			this.addEventListener(MouseEvent.MOUSE_OUT, function(e:MouseEvent):void
			{
				Mouse.cursor = MouseCursor.AUTO;
				isAnimation = false;
			});
		}
	}
}